<?php
namespace app\index\controller;
use think\Controller;
use think\Db;
use think\View;
use think\Session;
use think\Request;
class Common extends Controller{
    public $view;
    public $request;
    public $iphone = '0e35008f27a55f0e6eb9f065';
    public $android = 'e340006bcde85e764948b065';
    public $type;
    public $app_key;
    public function _initialize()
    {
        $this->request = Request::instance();
        $request = $this->request->request();

        $this->app_name = '';
        if(isset($request)){
            if(isset($request['s'])){
                $request = $request['s'];
                if(strstr($request, $this->iphone)){
                    $this->type = 1;
                    $this->app_key = $this->iphone;
                    $this->app_name = 'iphone';
                }
                if(strstr($request, $this->android)){
                    $this->type = 2;
                    $this->app_key = $this->android;
                    $this->app_name = 'android';
                }
            }
        }

        if(!$this->request->isAjax()){
            $this->view = new View();
            $this->view->type = $this->type;
            $this->view->app_key = $this->app_key;
            $this->view->app_name = $this->app_name;
        }
    }
}